﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;


public partial class ATM : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Btthem_Click(object sender, EventArgs e)
    {
        DataSet ds;
        //Lay du lieu len select
        Dataprovider pa = new Dataprovider();
        ds = pa.get("Select * from ThongTinATM");

        //danh cho insert va update
        string thematm = "INSERT INTO [ThongTinATM]([MaKhuVuc],[TenmayATM],[Diachi],[Latitude],[Longtitude],[ThongTin],[IsActive]) values('" + ddlmakhuvuc.SelectedValue + "',N'" + Txttenmay.Text.Trim() + "',N'" + Txtdiachi.Text.Trim() + "','" + Txtlat.Text.Trim() + "','" + Txtlong.Text.Trim() + "',N'" + Txtthongtin.Text.Trim() + "','" + ddlkichhoat.SelectedValue + "')";
        bool ketqua = pa.ExeCuteNonQuery(thematm);
        WebMsgBox.Show(" Thêm thành công");
        // cbkhuvuc.selectvalue
        
    }
    protected void Btsua_Click(object sender, EventArgs e)
    {
        DataSet ds;
        //Lay du lieu len select
        Dataprovider pa = new Dataprovider();
        ds = pa.get("Select * from ThongTinATM");
        string suaatm = " Update ThongTinATM  set [MaKhuVuc]='" + ddlmakhuvuc.SelectedValue + "',[TenmayATM]='" + Txttenmay.Text.Trim() + "',[Diachi]='" + Txtdiachi.Text.Trim() + "',[Latitude]='" + Txtlat.Text.Trim() + "',[Longtitude]='" + Txtlong.Text.Trim() + "',[ThongTin]='" + Txtthongtin.Text.Trim() + "',[IsActive]='" + ddlkichhoat.SelectedValue+ "' where [MaATM]='" + TxtmaATM.Text.Trim() + "'";
           bool ketqua = pa.ExeCuteNonQuery(suaatm);
           WebMsgBox.Show(" Sửa thành công");
    }
    protected void Btxoa_Click(object sender, EventArgs e)
    {
        DataSet ds;
        Dataprovider pa = new Dataprovider();
        ds = pa.get("Select * from ThongTinATM");
        string xoaatm = "Delete from ThongTinATM where MaATM='" + TxtmaATM.Text.Trim() + "'";
        bool ketqua = pa.ExeCuteNonQuery(xoaatm);
        WebMsgBox.Show(" Xóa thành công");
    }
}